#!  python
# -*- coding: UTF-8 -*-
'''
@Author ：Star
@Date ：2022/10/28  
'''


import unittest
# from TestBaidu import TestBaidu
# from TestBaidu2 import TestBaidu2
import time
import os
from HTMLTestRunner import HTMLTestRunner


now  = time.localtime()  #获取当前时间
print(now)
formattime = time.strftime("%Y%m%d-%H-%M-%S",now)
print(formattime)
report_dir = "./reports/"
report_file = report_dir + formattime+"report.html"

# 判断reports目录是否存在，如果不存在就创建目录
if not os.path.exists(report_dir):
    os.mkdir(report_dir)
with open(report_file, "wb") as fl:
    module_path = "./"
    discover = unittest.defaultTestLoader.discover(start_dir=module_path, pattern="test_ddtbaidu*.py")
    runner = HTMLTestRunner(title=report_file, description='ddt_baidu测试', stream=fl)
    runner.run(discover)